package com.medvalley.tcm.utils;

import com.google.common.base.Charsets;
import com.google.common.hash.Hashing;

import java.nio.charset.Charset;

public class EncryptUtils {
    private static final String KEY_ALGORITHM = "AES";
    private static final String CIPHER_ALGORITHM = "AES/ECB/PKCS5Padding";
    private static final Charset UTF8 = Charset.forName("UTF-8");

    public static String md5(String source) {
        return Hashing.md5().newHasher().putString(source, Charsets.UTF_8).hash().toString();
    }

    public static String sha256(String source) {
        String after = Hashing.sha256().newHasher().putString(source, Charsets.UTF_8).hash().toString().toUpperCase();
        return after;
    }

//    public static void main(String[] args) throws NoSuchPaddingException, BadPaddingException, NoSuchAlgorithmException, IllegalBlockSizeException, UnsupportedEncodingException, InvalidKeyException {
//        System.out.println(md5(AESUtil.encrypt("phone=13821330299&timestamp=1563861884674","9Q7QR7LBxaQ82ACa")));
//    }
}
